remotemanager.transport.transport module¶
Baseclass for any file transfer
- class remotemanager.transport.transport.Transport(url=None, dir_mode: bool = False, flags: str = None, verbose: None | int | bool | Verbosity = None, *args, **kwargs)[source]¶
Baseclass for file transfer
- Parameters:
url (URL) – url to extract remote address from
dir_mode – compatibility mode for systems that do not accept multiple explicit files per transfer, copies files to a directory then pulls it
- queue_for_push(files: [<class 'list'>, <class 'str'>, <class 'remotemanager.storage.trackedfile.TrackedFile'>], local: str = None, remote: str = None)[source]¶
Queue file(s) for sending (pushing)
- Parameters:
files (list[str], str, TrackedFile) – list of files (or file) to add to push queue
local (str) – local/origin folder for the file(s)
remote (str) – remote/destination folder for the file(s)
- Returns:
None
- queue_for_pull(files: [<class 'list'>, <class 'str'>, <class 'remotemanager.storage.trackedfile.TrackedFile'>], local: str = None, remote: str = None)[source]¶
Queue file(s) for retrieving (pulling)
- Parameters:
files (list[str], str, TrackedFile) – list of files (or file) to add to pull queue
local (str) – local/destination folder for the file(s)
remote (str) – remote/origin folder for the file(s)
- Returns:
None
- add_transfer(files: [<class 'list'>, <class 'str'>], origin: str | None, target: str | None, mode: str)[source]¶
Create a transfer to be executed. The ordering of the origin/target files should be considered as this transport instance being a “tunnel” between wherever it is executed (origin), and the destination (target)
- Parameters:
files (list[str], str) – list of files (or file) to add to pull queue
origin (str) – origin folder for the file(s)
target (str) – target folder for the file(s)
(str (mode) – “push” or “pull”): transfer mode. Chooses where the remote address is placed
- Returns:
None
- property transfers: dict¶
Return the current transfer dict
- Returns (dict):
{paths: files} transfer dict
- property address¶
return the remote address
- Returns (str):
the remote address
- cmd(primary: str, secondary: str) str [source]¶
Returns a formatted command for issuing transfers. It is left to the developer to implement this method when adding more transport classes.
The implementation should take two strings as arguments, primary and secondary:
- Parameters:
primary (str) –
The source folder, containing the files for transfer. Input will be semi-formatted already in bash form.
e.g. directory_name/{file1,file2,file3,…,fileN}
secondary (str) – The destination folder for the files
At its most basic:
``` def cmd(self, primary, secondary):
cmd = “command {primary} {secondary}” base = cmd.format(primary=primary, secondary=secondary) return base
You can, of course, extend upon this. View the included transport methods for ideas on how to do this.
- Returns (str):
formatted command for issuing a transfer
- transfer(dry_run: bool = False, prepend: bool = True, raise_errors: bool | None = None, dir_mode: bool | None = None, verbose: None | int | bool | Verbosity = None)[source]¶
Perform the actual transfer
- Parameters:
dry_run (bool) – do not perform command, just return the command(s) to be executed
prepend (bool) – enable forced cmd prepending
raise_errors (bool) – will not raise any stderr if False
dir_mode – compatibility mode for systems that do not accept multiple explicit files per transfer, copies files to a directory then pulls it
- Returns (str, None):
the dry run string, or None